import http from "@/http/index.ts"
import {SysRole, RoleListParam, AssignMenuParam, RoleDataScopeParam} from "@/api/role/type.ts"
// 新增角色
export const addApi = (data: SysRole) => {
    return http.post("/role/createRole", data)
}

// 分页查询角色列表
export const getListApi = (data: RoleListParam) => {
    return http.get("/role/getRoleList", data)
}

// 修改角色
export const editApi = (data: SysRole) => {
    return http.put("/role/updateRole", data)
}

// 删除
export const deleteApi = (roleId: number) => {
    return http.delete(`/role/deleteRole/${roleId}`)
}

// 获取角色下拉列表
export const getSelectApi = () => {
    return http.get("/role/selectRoleList")
}

//给角色分配菜单
export const saveAssignApi = (data:AssignMenuParam) => {
    return http.post("/role/doAssign",data)
}

// 获取数据权限
export const getRoleDataScope = (roleId:number) => {
    return http.get(`/role/getRoleDataScope/${roleId}`)
}

// 保存角色数据权限
export const assignRoleData = (data:RoleDataScopeParam) => {
    return http.post('/role/assignRoleData',data)
}


